Skip to content

Conversation

jayschwa
Copy link
Contributor

@jayschwa jayschwa commented Apr 17, 2025

This may be a breaking change for callers that depend on the return type being identical to the input type. For example, sign(i32) * i8 + i8 could now overflow. Callers can add an explicit type annotation to avoid that situation.

If Zig ever allows small integer types to coerce to floats (see #18614), then it might make sense to always return an integer. In the meantime, I figured it would be too annoying for users dealing with floats.

@jayschwa jayschwa force-pushed the narrow-math-sign-ints branch 2 times, most recently from b35e4ce to 09f03f6 Compare April 18, 2025 19:12
This may be a breaking change for callers that depend on the return type
being identical to the input type. For example, `sign(i32) * i8 + i8`
could now overflow. Callers can add an explicit type annotation to avoid
that situation.

If Zig ever allows small integer types to coerce to floats (see ziglang#18614),
then it might make sense to always return an integer. In the meantime,
I figured it would be too annoying for users dealing with floats.
@jayschwa jayschwa force-pushed the narrow-math-sign-ints branch from 09f03f6 to 8f7598e Compare July 28, 2025 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant